package com.yanqu.road.server.cmd.estatewar;

import com.yanqu.road.pb.estatewar.EstateWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.EstateWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

@Cmd(code = Protocol.S_ESTATE_WAR_WORSHIP, desc = "膜拜")
public class EstateWarWorshipCmd extends AbstractCommand {

	private int type;

	private EstateWarProto.EstateWarWorshipRespMsg.Builder respMsg = null;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		EstateWarProto.EstateWarWorshipReqMsg reqMsg = EstateWarProto.EstateWarWorshipReqMsg.parseFrom(packet.getBytes());
		type = reqMsg.getType();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		respMsg = EstateWarMgr.estateWarWorship(player,type);
	}

	@Override
	public void sendData(GamePlayer player) {
		player.sendPacket(Protocol.U_ESTATE_WAR_WORSHIP, respMsg);
	}

}
